package com.controller;

import com.common.mybaits.CustomPage;
import com.domain.DTO.UserDto;
import com.domain.VO.FlightClassVO;
import com.domain.VO.UserVO;
import com.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import com.common.result.ResponseResultAdvice;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 大忽悠
 * @create 2022/9/15 11:09
 */
@Validated
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@ResponseResultAdvice
@Api(tags="用户请求")
public class UserController {
    private final IUserService iUserService;

    @ApiOperation("添加用户")
    @PostMapping
    public void addFlightClass(UserVO userVO) {
         iUserService.save(userVO);
    }

    @ApiOperation("删除用户")
    @DeleteMapping
    public void removeUser(@RequestParam("id")Integer id) {
        iUserService.removeById(id);
    }

    @ApiOperation("查询所有用户")
    @GetMapping("/list")
    public List<UserDto> listUser(CustomPage customPage){
        return iUserService.list(customPage);
    }
}
